﻿using System;
using System.Collections.Generic;
using IllusionUtility.GetUtility;
using UnityEngine;

// Token: 0x0200025A RID: 602
public class AreolaSize
{
	// Token: 0x06000E29 RID: 3625 RVA: 0x00063C08 File Offset: 0x00061E08
	public virtual bool Init(GameObject obj, global::UVData uvData)
	{
		string[] array = new string[]
		{
			"cf_O_tikubiL_00",
			"cf_O_tikubiR_00"
		};
		for (int i = 0; i < 2; i++)
		{
			this.objNip[i] = obj.transform.FindLoop(array[i]);
		}
		this.CloneMesh();
		string[] array2 = new string[]
		{
			"cf_O_tikubiL_00",
			"cf_O_tikubiR_00",
			"cf_O_tikubiL_01",
			"cf_O_tikubiR_01"
		};
		int[] array3 = new int[]
		{
			0,
			1,
			0,
			1
		};
		int[] array4 = new int[]
		{
			0,
			0,
			1,
			1
		};
		int num = 0;
		for (int j = 0; j < uvData.data.Count; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				if (!(array2[k] != uvData.data[j].ObjectName))
				{
					this.uv[array3[k], array4[k]] = new List<Vector2>();
					for (int l = 0; l < uvData.data[j].UV.Count; l++)
					{
						this.uv[array3[k], array4[k]].Add(uvData.data[j].UV[l]);
					}
					num++;
					break;
				}
			}
		}
		if (num != 4)
		{
			return false;
		}
		if (this.smrNip[0].sharedMesh.uv.Length != this.uv[0, 0].Count)
		{
			global::Debug.LogWarning("左乳輪のUVの数が違う");
			return false;
		}
		if (this.smrNip[1].sharedMesh.uv.Length != this.uv[1, 0].Count)
		{
			global::Debug.LogWarning("右乳輪のUVの数が違う");
			return false;
		}
		this.calc[0] = new Vector2[this.uv[0, 0].Count];
		this.calc[1] = new Vector2[this.uv[1, 0].Count];
		this.InitEnd = true;
		return true;
	}

	// Token: 0x06000E2A RID: 3626 RVA: 0x00063E40 File Offset: 0x00062040
	public virtual void Blend(float rate)
	{
		if (!this.InitEnd)
		{
			return;
		}
		for (int i = 0; i < 2; i++)
		{
			if (!(null == this.objNip[i]))
			{
				for (int j = 0; j < this.calc[i].Length; j++)
				{
					this.calc[i][j] = Vector2.Lerp(this.uv[i, 0][j], this.uv[i, 1][j], rate);
				}
				if (this.smrNip[i])
				{
					this.smrNip[i].sharedMesh.uv = this.calc[i];
				}
			}
		}
	}

	// Token: 0x06000E2B RID: 3627 RVA: 0x00063F0C File Offset: 0x0006210C
	public virtual void CloneMesh()
	{
		for (int i = 0; i < 2; i++)
		{
			this.smrNip[i] = this.objNip[i].GetComponent<SkinnedMeshRenderer>();
			if (this.smrNip[i] && this.smrNip[i].sharedMesh)
			{
				Mesh mesh = UnityEngine.Object.Instantiate<Mesh>(this.smrNip[i].sharedMesh);
				mesh.name = this.smrNip[i].sharedMesh.name;
				this.smrNip[i].sharedMesh = mesh;
			}
		}
	}

	// Token: 0x04000F0F RID: 3855
	protected GameObject[] objNip = new GameObject[2];

	// Token: 0x04000F10 RID: 3856
	protected SkinnedMeshRenderer[] smrNip = new SkinnedMeshRenderer[2];

	// Token: 0x04000F11 RID: 3857
	protected List<Vector2>[,] uv = new List<Vector2>[2, 2];

	// Token: 0x04000F12 RID: 3858
	protected Vector2[][] calc = new Vector2[2][];

	// Token: 0x04000F13 RID: 3859
	protected bool InitEnd;
}
